//
//  ByDocumentaryCellTitleView.m
//  caipiao_ios
//
//  Created by mc on 2018/8/17.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByDocumentaryCellTitleView.h"

@implementation ByDocumentaryCellTitleView

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat width = 30;
        if (frame.size.height > 60) {
            width = 45;
        }
        
        UIImageView *iconView = [[UIImageView alloc] init];
        [self addSubview:iconView];
        [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(10);
            make.centerY.equalTo(self).offset(0);
            make.size.mas_equalTo(CGSizeMake(width, width));
        }];
        iconView.layer.cornerRadius = width / 2.0;
        iconView.layer.masksToBounds = YES;
        iconView.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
        [iconView addGestureRecognizer:tap];
        
        UILabel *nickLabel = [[UILabel alloc] init];
        [self addSubview:nickLabel];
        [nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(iconView.mas_right).offset(10);
            make.centerY.equalTo(self).offset(0);
            make.size.mas_equalTo(CGSizeMake(70, 20));
        }];
        nickLabel.textColor = [UIColor blackColor];
        nickLabel.font = FONT(13);
        
        
        UILabel *recordLabel = [[UILabel alloc] init];
        [self addSubview:recordLabel];
        [recordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(nickLabel.mas_right).offset(15);
            make.centerY.equalTo(self).offset(0);
            make.size.mas_offset(CGSizeMake(50, 23));
        }];
        recordLabel.backgroundColor = rgba(248, 202, 188, 1);
        recordLabel.textColor = BY_THEME_COLOR;
        recordLabel.textAlignment = NSTextAlignmentCenter;
        recordLabel.font = FONT(12);
        recordLabel.layer.cornerRadius = 2;
        
        UILabel *timeLabel = [[UILabel alloc] init];
        [self addSubview:timeLabel];
        [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(recordLabel.mas_right).offset(10);
            make.right.equalTo(self).offset(-10);
            make.height.mas_equalTo(@15);
            make.centerY.equalTo(self).offset(0);
        }];
        timeLabel.textColor = [UIColor lightGrayColor];
        timeLabel.font = FONT(12);
        timeLabel.textAlignment = NSTextAlignmentRight;
        
        self.iconView = iconView;
        self.nickLabel = nickLabel;
        self.timeLabel = timeLabel;
        self.recordLabel = recordLabel;
        
    }
    return self;
}

- (void)tapAction:(UITapGestureRecognizer *)tap{
    if (self.tapViewBlock) {
        self.tapViewBlock();
    }
    
}



@end
